
var aspxURL = "http://www.pomoho.com/do/special/specialsingle.aspx";

function $C(className, parent){
	var elems = (document.getElementById(parent)||document.body).getElementsByTagName("*");
	var result = [];
	for(i=0; i<elems.length; i++){
		if((" "+elems[i].className+" ").indexOf(" "+className+" ") != -1){
			result.push(elems[i]);
		}
	}
	return result;
}

String.prototype.trim = function(){return this.replace(/(^[\s]*)|([\s]*$)/g,"")}

function f_alert(name)
{
	alert(name);
}
function DoMovieAction( subjectID, emitStatus )
{
	if (_is_login) {
		Pui.loadScript(aspxURL + "?subjectid=" + subjectID + "&emitstatus=" + emitStatus + "&alerttype=1");
	}else{
		flag=6;
		_subjectID=subjectID;_emitStatus=emitStatus;
		Pui.newSH.loginfo();
	}
	
}
function CopyText(s){
              //IE            
              if(window.clipboardData)
              {
                window.clipboardData.clearData();
                window.clipboardData.setData("Text", s);
              }
              //FireFox
              else if (window.netscape)
              {
                  try
                  {
                      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                  }
                  catch (e)
                  {
                      alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试");
                      return false;
                  }
                  var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
                  if (!clip)
                      return;
                  var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
                  if (!trans)
                      return;
                  trans.addDataFlavor('text/unicode');
                  var str = new Object();
                  var len = new Object();
                  var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
                  var copytext = s;
                  str.data = copytext;
                  trans.setTransferData("text/unicode",str,copytext.length*2);
                  var clipid = Components.interfaces.nsIClipboard;
                  if (!clip)
                  return false;
                  clip.setData(trans,null,clipid.kGlobalClipboard);
              }
              alert("地址已复制到剪切板！");
          }

function Trim(s)
{
	return s.replace(/(^\s*)|(\s*$)/g,"");   
}

function GetCookie(sName)
{
	//document.domain = "pomoho.com";
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
		return unescape(aCookie[i].replace(sName + "=", ""));
	}
	return null;
}

//发表评论
function SendBlog(subjectID)
{	
	var sNickName = '游客';
    var sSpaceName = '';
	var u_name = sNickName;

	var sNoticeCookie = GetCookie("PomohoNewNotice");	
	if (sNoticeCookie != null)
	{
		var arrNotice = sNoticeCookie.split("$***$");	
		sNickName = arrNotice[6];
		//sSpaceName = 'href="http://home.pomoho.com/' + arrNotice[7] + '.shtml"';
		sSpaceName = 'href="http://www.pomoho.com/ui/blogadmin.aspx?_type=preview"';
		u_name = '<a ' + sSpaceName + ' target="_blank" title="' + sNickName + '" >' + sNickName + '</a>';
	}

	scontent = Trim(document.getElementById("article").value);
	
	if (scontent.length < 5 || scontent.length > 200)
	{
		alert('您发的评论字数必须大于5个字，小于200个字');
		document.getElementById("article").focus();
		return;
	}
	
	scontent = scontent.replace("<", "&lt;").replace(">", "&gt;").replace(/&/g, "<--@@-@@-->");
	
	Pui.loadScript(aspxURL + "?subjectid="+subjectID + "&alerttype=1" + "&objtype=1" +"&content="+ escape(scontent));
	
	var time = new Date();
	var t_year = time.getFullYear();
	var f_time = t_year + "-" + parseInt(time.getMonth()+1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
	var div = null;	
	var div  = document.createElement("DIV");
	div.innerHTML = '<div class="mDocument">'
				 + '	   <div class="photo"><a ' + sSpaceName + ' target="_blank"><img src="http://static.pomoho.com/pics/user_default.gif" alt="' + sNickName + '" /></a></div>'
				 + '			<div class="detail">'
				 + '				<span class="n_user">'+u_name+'</span>'
				 + '				<p class="text">' + repEm(scontent) + '</p>'
				 + '			</div>'
				 + '			<div class="handle">'
				 + '				<span class="t_release">' + f_time + '</span>'
				 + '			</div>'
				 + '		</div>'
				 + '	</div>';
	
	var divCommentList = $C("cl")[0];
	
	divCommentList.insertBefore( div, divCommentList.firstChild );
	var spanList = $C("commentcount");
	var sCommentCount = 0;
	if( spanList!=null ){
		for( var i=0; i<spanList.length; i++ ) {
			var iCount = parseInt(spanList[i].innerHTML);			
			sCommentCount = iCount+1;
			spanList[i].innerHTML = sCommentCount.toString();
		}
	}
	document.getElementById("article").value = "";
}

//选择评论图标
function post_em(sEm)
{
	document.getElementById("article").value += "[em" + sEm + "]";
}

function repEm(s)
{
	return s.replace(/\[em(\d{1,})\]/g, "<img src='http://static.pomoho.com/images/em/em$1.gif' />");
}

//收藏页面
function bookmark()
{
	var title=document.title
	var url=document.location.href
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
	else if( window.opera && window.print ){
	var mbm = document.createElement('a');
	mbm.setAttribute('rel','sidebar');
	mbm.setAttribute('href',url);
	mbm.setAttribute('title',title);
	mbm.click();}
	else if( document.all ) window.external.AddFavorite( url, title);
}

function getNextPlayURL() {
	var obj = $('#VideoList .ac').next().find('.title a');
	if(obj.attr('href') != undefined) {
		$('#Layout_1 .vp h2').html(obj.attr('title'));
		$('#VideoList .ac').removeClass('ac').next().addClass('ac');
		var ss = obj.attr('href').split('/');
		thiszhuanMovie("player").getvideonum(ss[ss.length - 1]);

		Pui.loadScript("http://video.pomoho.com/getvideoinfo.aspx?fivid=" + ss[ss.length - 1]);
		
		return "1";
	} else {
		thiszhuanMovie("player").getvideonum(0);
		return "1";
	}
}
function thiszhuanMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function ReadVideoInfo(sT_Release,sV_intro,sHonor,sC_view,sC_review,sC_bookmark,sV_type,sV_tag)
{
	$('#Layout_1 .vp .detail .t_release').html(sT_Release);
	$('#Layout_1 .vp .detail .v_intro').html(sV_intro);

	$('#Layout_1 .vp .detail .de .s .l_strong').html(sHonor);
	$('#Layout_1 .vp .detail .de .s .c_view').html(sC_view);
	$('#Layout_1 .vp .detail .de .s .c_review').html(sC_review);
	$('#Layout_1 .vp .detail .de .s .c_bookmark').html(sC_bookmark);

	$('#Layout_1 .vp .detail .de .v_type').html(sV_type);
	$('#Layout_1 .vp .detail .de .v_tag').html(sV_tag);
}

function RefSpecial(res){
	var str;
	if(typeof(res)=="undefined"||res.length<1){
		str+='<li style="background:#fff;text-align:center">没有相关数据</li></ul>';
		$(str).appendTo("#SpecialRef ul");
		return	
	}
	var vLen=res.length;
	var paras='';
	
	str += '<li class="s">';
	for (var i = 0; i < vLen; i++) {
		if (i < 2) {
			str += '<div class="special" id="special_'+res[i].id+'">';
			str += '	<div class="p"><a title="'+res[i].title+'" href="http://special.pomoho.com/'+res[i].specialSpace+',set,1" target="_blank"><img src="'+res[i].pic+'" alt="'+res[i].title+'" /><span>'+res[i].title+'</span></a></div>';
			str += '	<div class="d">';
			str += '		<div class="c_video">视频：<span></span></div>';
			str += '		<div class="c_view">人气：<span></span></div>';
			str += '	</div>';
			str += '</div>';
			paras=paras+res[i].id+",";
		}
		if(i==1){str += '</li>';}
		if (i >=2) {
			str += '<li>';
			str += '	<div class="special" id="special_'+res[i].id+'">';
			str += '		<div class="title"><a title="'+res[i].title+'" href="http://special.pomoho.com/'+res[i].specialSpace+',set,1" target="_blank">'+res[i].title+'</a></div>';
			str += '		<div class="c_video">视频：<span></span></div>';
			str += '		<div class="c_view">人气：<span></span></div>';
			str += '	</div>';
			str += '</li>';
			paras=paras+res[i].id+",";
		}	
	}
	$(str).appendTo("#SpecialRef ul");
	paras=paras.substr(0,paras.length-1);
	Pui.loadScript("http://live.pomoho.com/getxmldata.aspx?type=3&ids="+paras+"&random=12361329102291813");
	
}
